package com.myz.rabbitmq.study5;

import com.myz.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

// 生产者
public class EmitLog {
    // exchange name
    public static final String EXCHANGE_NAME = "logs";

    public static void main(String[] args) throws Exception {
        // get channel
        Channel channel = RabbitMqUtils.getChannel();
        // register exchange
        channel.exchangeDeclare(EXCHANGE_NAME,"fanout");
        // input
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String message = sc.next();
            channel.basicPublish(EXCHANGE_NAME,"",null,message.getBytes("UTF-8"));
        }
    }
}
